<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>注册页面</title>
</head>


<%

	String content_path = request.getContextPath();
	String base_path = request.getScheme() + "://"
		+ request.getServerName() + ":" + request.getServerPort()
		+ content_path;
	
%>

<%@ page import="data.User" %>
<%@ page import="data.Author" %>
<%

	boolean state_login = false;
	boolean is_author = false;
	
	Integer user_id = (Integer)session.getAttribute(User.Attribute.ID.getFullName());
	String username = (String)session.getAttribute(User.Attribute.USERNAME.getFullName());
	String password = (String)session.getAttribute(User.Attribute.PASSWORD.getFullName());
	
	if (username != null && password != null)
		if (User.checkUser(username, password))
			state_login = true;
	
	if (user_id != null)
		if (Author.hasAuthor(user_id))
			is_author = true;
%>



<script type="text/javascript">

</script>


<body>

	<form id="form_register" action="<%=base_path%>/UserServlet" method="post" accept-charset="UTF-8" target="iframe1" style="white-space: pre-wrap;">
	<input type="hidden" name="type" value="REGISTER">
		用户名：<input id="input_username" type="text" name="username"/>
		 密 码： <input id="input_password1" type="password" name="password"/>
                                        <input type="submit" value="注册"/>
	</form>
	
	
	<form id="form_register_author" action="<%=base_path%>/AuthorServlet" method="post" accept-charset="UTF-8" target="iframe1" style="display: none;white-space: pre-wrap;">
	<input type="hidden" name="type" value="REGISTER">
		笔名：<input id="input_username" type="text" name="pen_name"/>
		                     <input type="submit" value="注册"/>
	</form>
	
	<br>
	<a href="#" onclick="javascript:history.back(-1);">返回上一页</a>
	<br>
	<iframe name="iframe1" width="80%" height="300px" frameborder="no" style="border:none;"></iframe>
</body>


<script>

	if (<%=state_login%> && !<%=is_author%>)
	{
		document.getElementById("form_register").style.display = "none";
		document.getElementById("form_register_author").style.display = "block";
	}

</script>


</html>









